<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的计划清单</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        
        body {
            background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: flex-start;
            padding: 40px 20px;
        }
        
        .container {
            width: 100%;
            max-width: 600px;
            background: white;
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            overflow: hidden;
        }
        
        header {
            background: #4a6fc7;
            color: white;
            padding: 25px;
            text-align: center;
        }
        
        h1 {
            font-size: 28px;
            margin-bottom: 10px;
        }
        
        .stats {
            display: flex;
            justify-content: center;
            gap: 20px;
            margin-top: 10px;
        }
        
        .stat-item {
            background: rgba(255, 255, 255, 0.2);
            padding: 8px 15px;
            border-radius: 20px;
            font-size: 14px;
        }
        
        .input-section {
            padding: 20px;
            border-bottom: 1px solid #eee;
        }
        
        .input-group {
            display: flex;
            gap: 10px;
        }
        
        input {
            flex: 1;
            padding: 14px;
            border: 2px solid #ddd;
            border-radius: 8px;
            font-size: 16px;
            transition: border-color 0.3s;
        }
        
        input:focus {
            outline: none;
            border-color: #4a6fc7;
        }
        
        button {
            background: #4a6fc7;
            color: white;
            border: none;
            border-radius: 8px;
            padding: 0 20px;
            cursor: pointer;
            font-size: 16px;
            font-weight: 500;
            transition: background 0.3s;
        }
        
        button:hover {
            background: #3a5ca9;
        }
        
        .tasks-section {
            padding: 10px 20px 30px;
        }
        
        .task-list {
            list-style: none;
            margin-top: 10px;
        }
        
        .task-item {
            display: flex;
            align-items: center;
            padding: 15px;
            margin-bottom: 12px;
            background: #f8f9fa;
            border-radius: 8px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
            transition: transform 0.2s;
        }
        
        .task-item:hover {
            transform: translateY(-2px);
        }
        
        .task-checkbox {
            margin-right: 15px;
            width: 20px;
            height: 20px;
            cursor: pointer;
        }
        
        .task-text {
            flex: 1;
            font-size: 16px;
            word-break: break-word;
        }
        
        .task-completed .task-text {
            text-decoration: line-through;
            color: #888;
        }
        
        .delete-btn {
            background: #ff4757;
            color: white;
            border: none;
            border-radius: 6px;
            padding: 8px 12px;
            cursor: pointer;
            font-size: 13px;
            margin-left: 10px;
        }
        
        .delete-btn:hover {
            background: #ff2e43;
        }
        
        .empty-state {
            text-align: center;
            padding: 40px 20px;
            color: #888;
        }
        
        .empty-state img {
            max-width: 200px;
            margin-bottom: 20px;
            opacity: 0.7;
        }
        
        @media (max-width: 600px) {
            .input-group {
                flex-direction: column;
            }
            
            button {
                padding: 14px;
            }
            
            .stat-item {
                font-size: 12px;
                padding: 6px 10px;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1>我的计划清单</h1>
            <p>记录您的任务与目标</p>
            <div class="stats">
                <div class="stat-item">总任务: <span id="total-count">0</span></div>
                <div class="stat-item">已完成: <span id="completed-count">0</span></div>
                <div class="stat-item">未完成: <span id="incomplete-count">0</span></div>
            </div>
        </header>
        
        <div class="input-section">
            <div class="input-group">
                <input type="text" id="task-input" placeholder="输入新的计划任务...">
                <button id="add-task-btn">添加任务</button>
            </div>
        </div>
        
        <div class="tasks-section">
            <h2>任务列表</h2>
            <ul class="task-list" id="task-list">
                <div class="empty-state" id="empty-state">
                    <img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='120' height='120'%3E%3Cpath fill='%23ccc' d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-1-13h2v6h-2zm0 8h2v2h-2z'/%3E%3C/svg%3E" alt="No tasks">
                    <p>暂无任务，请添加新任务</p>
                </div>
            </ul>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const taskInput = document.getElementById('task-input');
            const addTaskBtn = document.getElementById('add-task-btn');
            const taskList = document.getElementById('task-list');
            const emptyState = document.getElementById('empty-state');
            const totalCountEl = document.getElementById('total-count');
            const completedCountEl = document.getElementById('completed-count');
            const incompleteCountEl = document.getElementById('incomplete-count');
            
            let tasks = JSON.parse(localStorage.getItem('tasks')) || [];
            
            // 初始化渲染
            renderTasks();
            updateStats();
            
            // 添加任务
            addTaskBtn.addEventListener('click', addTask);
            taskInput.addEventListener('keypress', function(e) {
                if (e.key === 'Enter') {
                    addTask();
                }
            });
            
            function addTask() {
                const taskText = taskInput.value.trim();
                if (taskText === '') return;
                
                const newTask = {
                    id: Date.now(),
                    text: taskText,
                    completed: false,
                    timestamp: new Date().toLocaleString()
                };
                
                tasks.push(newTask);
                saveTasks();
                renderTasks();
                updateStats();
                
                taskInput.value = '';
                taskInput.focus();
            }
            
            function deleteTask(id) {
                tasks = tasks.filter(task => task.id !== id);
                saveTasks();
                renderTasks();
                updateStats();
            }
            
            function toggleCompleted(id) {
                tasks = tasks.map(task => {
                    if (task.id === id) {
                        return {...task, completed: !task.completed};
                    }
                    return task;
                });
                
                saveTasks();
                renderTasks();
                updateStats();
            }
            
            function saveTasks() {
                localStorage.setItem('tasks', JSON.stringify(tasks));
            }
            
            function renderTasks() {
                if (tasks.length === 0) {
                    emptyState.style.display = 'block';
                    taskList.innerHTML = '';
                    return;
                }
                
                emptyState.style.display = 'none';
                
                taskList.innerHTML = tasks.map(task => `
                    <li class="task-item ${task.completed ? 'task-completed' : ''}">
                        <input type="checkbox" class="task-checkbox" ${task.completed ? 'checked' : ''} 
                            onchange="toggleCompleted(${task.id})">
                        <span class="task-text">${task.text}</span>
                        <small style="color: #888; margin-left: 10px; font-size: 12px;">${task.timestamp}</small>
                        <button class="delete-btn" onclick="deleteTask(${task.id})">删除</button>
                    </li>
                `).join('');
            }
            
            function updateStats() {
                const total = tasks.length;
                const completed = tasks.filter(task => task.completed).length;
                const incomplete = total - completed;
                
                totalCountEl.textContent = total;
                completedCountEl.textContent = completed;
                incompleteCountEl.textContent = incomplete;
            }
            
            // 使函数在全局可用，以便内联事件处理程序可以访问
            window.toggleCompleted = toggleCompleted;
            window.deleteTask = deleteTask;
        });
    </script>
</body>
</html>